package study.job.spring.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Slf4j
@Service
public class AsyncService {

    public void sleep(long timeout) {
        log.info("doAsync_01 start >>>>>>>>>>");
        try {
            TimeUnit.SECONDS.sleep(timeout);
        } catch (Exception ex) {
        }
        log.info("doAsync_01 end >>>>>>>>>>");
    }

    public void throwEx() {
        log.info("throw exception");
        throw new RuntimeException("我是业务异常");
    }

    @Async("executor_2")
    public void doAsync1() {
        log.info("demo demo demo");
    }

    public void doAsync2() {
        log.info("demo demo demo");
    }
}
